package com.atguigu04.other.exer;

import java.io.*;
import java.lang.reflect.Constructor;
import java.util.Properties;

/**
 * ClassName: MyAnswer
 * Package: com.atguigu04.other.exer
 * Description:
 *
 * @Author BuTang
 * @Create 2023/6/25 11:45
 * @Version 1.0
 */
public class MyAnswer {
    public static void main(String[] args) throws Exception {
        Properties pro = new Properties();
        File file = new File("src/config.properties");
        InputStream fis = new FileInputStream(file);

        pro.load(fis);
        String fruitName = pro.getProperty("fruitName");



        //反射创建对象
        Class clazz = Class.forName(fruitName);
        Constructor fruit = clazz.getDeclaredConstructor(null);
        fruit.setAccessible(true);
        Fruit fruit1 = (Fruit) fruit.newInstance(null);
        Juicer juicer = new Juicer();
        juicer.run((fruit1));
    }
}
